package com.it.a01mystream;

import java.util.*;
import java.util.stream.Stream;

public class StreamDemo2 {
    public static void main(String[] args) {
        //1.如何获取List集合的Stream流？
        List<String> names = new ArrayList<>();
        Collections.addAll(names,"张三丰","张无忌","周志","赵明");
        Stream<String> stream = names.stream();
        //stream.filter(n -> n.length()>2).forEach(n -> System.out.println(n));

        //Set集合的Stream流
        Set<String> set = new HashSet<>();
        Collections.addAll(set,"张三丰","张无忌","周志","赵明");
        Stream<String> stream1 = set.stream();
        //stream1.filter(n -> n.contains("三")).forEach(n -> System.out.println(n));

        //如何获取数组的Steam流？
        String[] names2= {"张三丰","张无忌","周志","赵明"};
        Stream< String> s1= Arrays. stream(names2);
        Stream< String> s2= Stream. of(names2);
        System.out.println(s1);
        System.out.println(s2);
    }
}
